package de.akad.imp03.client.ui;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Panel;

public class ButtonWrapper implements ClickHandler {
	
	private Button button;
	private Panel panel;
	private HandlerCommand clickHandler;
	
	public ButtonWrapper(Button button) {
		this.button = button;
	}
	
	public void addToPanel(Panel panel) {
		this.panel = panel;
		panel.add(button);
	}

	public void setOnClickHandler(HandlerCommand c) {
		clickHandler = c;
	}
	
	@Override
	public void onClick(ClickEvent event) {
		if (clickHandler != null) {
			clickHandler.onAction();
		}
	}

}
